package idv.arthur.work;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

/**
 * Servlet implementation class DelMRitem
 */ 
public class QueryTTT extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public QueryTTT() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	doPost(request,response);
    }

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		
		ResultTableSet resultTableSet = new ResultTableSet();
		
		int page = 1;
		int total_pages = 1;
		int count  = 3;
		
		ArrayList<Rows> rows = new ArrayList<Rows>();
		Rows row = new Rows();
		String[] cell = new String[5];
		cell[1] = "Verify_01";
		cell[2] = "驗證環境一號";
		cell[3] = "842297 (郭啟揚)";
		cell[4] = "2012-09-28 09:49:04";
		row.setCell(cell);
		rows.add(row);
		cell = new String[5];
		cell[1] = "OnLine_01";
		cell[2] = "現場環境一號";
		cell[3] = "842297 (郭啟揚)";
		cell[4] = "2012-09-28 09:49:04";
		Rows row2 = new Rows();
		row2.setCell(cell);
		rows.add(row2);
		cell = new String[5];
		cell[1] = "Verify_02";
		cell[2] = "驗證環境二號";
		cell[3] = "842297 (郭啟揚)";
		cell[4] = "2012-09-28 09:49:04";
		Rows row3 = new Rows();
		row3.setCell(cell);
		rows.add(row3);
		
		resultTableSet.setRows(rows);
		resultTableSet.setPage(String.valueOf(page));
		resultTableSet.setTotal(total_pages);
		resultTableSet.setRecords(String.valueOf(count));
		
		response.setContentType("application/json");
		response.setCharacterEncoding("UTF-8");
		response.getWriter().write(new Gson().toJson(resultTableSet));	
	}
}

